<?php 
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
session_start(); 
} 

$sqlprofile = mysql_query("SELECT e.FullName,e.CMND,e.BankName,e.BankAccount,e.Phone,e.Email,e.Address,DATE_FORMAT(e.Birthday,'%Y-%m-%d') as Birthday  
 FROM `employee` e WHERE e.IDEmployee = '$id_employee';");
$row = mysql_fetch_assoc($sqlprofile);
$fname = $row[FullName];
$indentity = $row[CMND];
$bankname = $row[BankName];
$bankaccount = $row[BankAccount];
$phone = $row[Phone];
$email = $row[Email];
$address = $row[Address];
$birthday = $row[Birthday];
?>
<link  href="admin/css/jsDatePick_ltr.min.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="admin/css/jsDatePick.min.1.3.js"></script>
<script type="text/javascript" src="admin/js/md5.js"></script>
<script type="text/javascript">

window.onload = function(){
	new JsDatePick({
		useMode:2,
		target:"birthday",

		dateFormat:"%Y-%m-%d"
	});
};

function checkvalidatePassword(){
	var oldpass = document.getElementById("oldpass").value;
	var newpass = document.getElementById("newpass").value;
	var repass = document.getElementById("repass").value;

	var passemp = document.getElementById("hidepass").value;
	var md5oldpass = MD5(oldpass).toUpperCase();
	
	if(oldpass.length==0){
		alert('<?=$l_alertoldpass?>');
		return false;
	}
	else if(newpass.length==0){
		alert('<?=$l_alertnewpass?>');
		return false;
	}
	else if(repass.length==0){
		alert('<?=$l_alertrepass?>');
		return false;
	}
	else if(newpass != repass){
		alert('<?=$l_alertpassandrepass?>');
		return false;
	}else if(md5oldpass != passemp){
		alert('<?=$l_oldpassnotcorrect?>');
		return false;
	}
}

function checkValidateProfile(){
	var fullname = document.getElementById("funame").value;
	if(fullname.length==0){
		alert('<?=$l_alertfullname?>');
		return false;
	}
	var identity = document.getElementById("identity").value;
	if(identity.length==0){
		alert('<?=$l_alertidentitynum?>');
		return false;
	}
	var bankname = document.getElementById("bankname").value;
	if(bankname.length==0){
		alert('<?=$l_alertbankname?>');
		return false;
	}
	var accountnum = document.getElementById("accountnumber").value;
	if(accountnum.length==0){
		alert('<?=$l_alertbankacc?>');
		return false;
	}
	var phone = document.getElementById("phone").value;
	if(phone.length==0){
		alert('<?=$l_alertphone?>');
		return false;
	}
	var email = document.getElementById("mail").value;
	if(email.length==0){
		alert('<?=$l_alertemail?>');
		return false;
	}
	var address = document.getElementById("address").value;
	if(address.length==0){
		alert('<?=$l_alertaddress?>');
		return false;
	}
	var birthday = document.getElementById("birthday").value;
	if(birthday.length==0){
		alert('<?=$l_alertbirthday?>');
		return false;
	}
}


</script>

<script type="text/javascript">
$(document).ready(function(){
<?php 
if (isset($_SESSION['alert'])){?>
	alert("<?=$l_capnhatthanhcong?>");
<?php unset($_SESSION['alert']);}
?>
<?php 
		if (isset($_SESSION['alertpass'])){?>
			alert("<?=$l_capnhatthanhcong?>");
		<?php unset($_SESSION['alertpass']);}
		?>

});
</script>

<?php $checkpass = mysql_query("Select Password from employee where IDEmployee='$id_employee';");
		$vl = mysql_fetch_assoc($checkpass);?>
<div id="contains" style="background-color: #edf4f7;">

	<div class="title"></div>
	<div class="body">
		<div style="height: 10px;"></div>
		<div class="changePass">
			<span id="head"><?php echo $l_changepassword?></span>
			<div id="content">
				<div id="messPass"
					style="padding: 10px 0px 5px 0px; width: 400px; margin: auto; text-align: center; color: red">
					<div id="messForm"></div>
				</div>
				<form action="admin/privateinfor/update-change-password.php" id="changepass" method="post" onsubmit="return checkvalidatePassword();">
				<input type="hidden" id="hidepass" name="hidepass" value="<?=$vl[Password]?>">
				<input type="hidden" id="hiddenemployee" name="hiddenemployee" value="<?=$id_employee?>">
				<table style="border-bottom: 1px dotted silver;width: 100%">
				
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_oldpass?> : <span style="color: red">*</span></td>
						<td style="width: 80%"><input type="password" id="oldpass"
							name="oldpass" class="textfiledProfile" />
						</td>
					</tr>
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_newpassword?> : <span style="color: red">*</span></td>
						<td><input type="password" id="newpass" name="newpass"
							class="textfiledProfile" />
						</td>
					</tr>
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_retypepassword?> : <span style="color: red">*</span></td>
						<td><input type="password" id="repass" name="repass" class="textfiledProfile" />
						</td>
					</tr>
				</table>
				<div style="height: 10px;"></div>
				<div class="formFooter">
					<div style="float: left; color: red">(*) <?php echo $l_required?></div>
					<div style="float: right;">
						<input id="updatepass" name="updatepass" 
							value="<?php echo $l_update?>" class="buttonNormal" type="submit" />
					</div>
				</div>
				</form>
				<div style="height: 20px;"></div>

			</div>
		</div>

		<div style="height: 20px;"></div>

		<div class="changeProfile" style="height: 170px">
			<span id="head"><?php echo $l_imageupload?></span>
			<div id="content" style="margin: 5px 0px 0px 0px;">
			<form action="#" method="post" enctype="multipart/form-data">
				<table cellspacing="3px">
					<tr>
						<td valign="top" width="170px"><input type="file" size="60"
							name="fileUpload" id="fileUpload" style="height: 26px; line-height: 26px; vertical-align: middle;"/>
						</td>
						<td><input type="submit" value="<?php echo $l_upload?>" name="uploadimage"
							 id="uploadimage" class="buttonNormal" /></td>
					</tr>
				</table></form>
				<div style="margin: 5px">
				<?php 
					if(isset($_POST['uploadimage']))
					{
	
					move_uploaded_file($_FILES['fileUpload']['tmp_name'], "upload/".$_FILES['fileUpload']['name']);
					$image =$_FILES['fileUpload']['name'];
					$url = "upload/".$_FILES['fileUpload']['name'];
					$sqlinsertlogo="update employee set Image='$url' where IDEmployee=".$id_employee;
					mysql_query($sqlinsertlogo);
				?>
			
				<?php }?>
				<?php $sqllogo =mysql_query("SELECT Image FROM employee  where IDEmployee=".$id_employee);
					$r = mysql_fetch_assoc($sqllogo);
				?>
					<img id="srcImage" width="100px" height="80px" src="<?php echo $r[Image]?>" />
				</div>
			</div>
		</div>

		<div style="height: 20px;"></div>

		<div class="changeProfile">
			<span id="head"><?php echo $l_changeprofile?></span>
			<div id="content">
				<div id="messPass"
					style="padding: 10px 0px 5px 0px; width: 400px; margin: auto; text-align: center; color: red">
					<div id="messForm"></div>
				</div>
				<form action="admin/privateinfor/update-change-profile.php">
				<input type="hidden" id="vlemployee" name="vlemployee" value="<?=$id_employee?>">
				<table style="border-bottom: 1px dotted silver;width: 100%;">
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_fullname?>:</td>
						<td style="width: 80%"><input type="text" id="funame"
							name="funame" class="textfiledProfile" value="<?php echo $fname;?>"/>
						</td>
					</tr>
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_cmnd?> :</td>
						<td><input type="text" id="identity" name="identity"
							class="textfiledProfile" value="<?php echo $indentity;?>"/>
						</td>
					</tr>
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_bankname?> :</td>
						<td><input type="text" name="bankname" class="textfiledProfile" value="<?php echo $bankname;?>"/>
						</td>
					</tr>

					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_accnum?>:</td>
						<td style="width: 80%"><input type="text" id="accountnumber"
							name="accountnumber" class="textfiledProfile" value="<?php echo $bankaccount;?>"/>
						</td>
					</tr>
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_phone?> :</td>
						<td><input type="text" id="phone" name="phone" value="<?php echo $phone;?>"
							class="textfiledProfile" />
						</td>
					</tr>
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_email?> :</td>
						<td><input type="text" name="mail" class="textfiledProfile" value="<?php echo $email;?>"/>
						</td>
					</tr>
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_address?> :</td>
						<td style="width: 80%"><input type="text" id="address"
							name="address" class="textfiledProfile" value="<?php echo $address;?>"/>
						</td>
					</tr>
					<tr>
						<td width="200px" class="tdFirst"><?php echo $l_birthday?> :</td>
						<td><input type="text" id="birthday" name="birthday" value="<?php echo $birthday;?>"
							class="textfiledProfile" />
						</td>
					</tr>


				</table>
				<div style="height: 10px;"></div>
				<div class="formFooter">
					<div style="float: left; "></div>
					<div style="float: right;">
						<input id="updateprofile" name="updateprofile"
							value="<?php echo $l_update?>" class="buttonNormal" type="submit" />
					</div>
				</div>
				</form>
				<div style="height: 20px;"></div>

			</div>
		</div>
<!-- 
		<div style="height: 20px;"></div>
		<div class="changeProfile">
			<span id="head"><?php echo $l_historyworking?></span>
			<div id="content" style="margin-top: 10px;">
<?php 
$historyworking = mysql_query("select DATE_FORMAT(TimeCheckIn,'%Y-%m-%d') as DateTime,DATE_FORMAT(TimeCheckIn,'%H:%i:%s') as TimeCheckIn,
			DATE_FORMAT(TimeCheckOut,'%H:%i:%s') as TimeCheckOut  from checkworktime where IDEmployee ='$id_employee");
?>
				<table style="width: 100%" class="rf-dt">
					<thead class="rf-dt-thd">
						<tr class="rf-dt-shdr">
							<th class="rf-dt-shdr-c" style="width: 5%"><?php echo $l_no?></th>
							<th class="rf-dt-shdr-c"  style="width: 31%"><?php echo $l_date?></th>
							<th class="rf-dt-shdr-c" style="width: 31%"><?php echo $l_timecheckin?></th>
							<th class="rf-dt-shdr-c" style="width: 31%"><?php echo $l_timecheckout?></th>
						</tr>
						<?php
							$i = 0;
						while ($row = mysql_fetch_array($historyworking)){
							$i ++;
							?>
						<tr>
							<td class="rf-dt-shdr-c"  style="background-color: #ffffff;font-weight: normal;font-size: 12px; width: 5%"><?php echo $i;?></td>
							<td class="rf-dt-shdr-c"  style="background-color: #ffffff;font-weight: normal;font-size: 12px; width: 31%"><?php echo $row[DateTime]?></td>
							<td class="rf-dt-shdr-c"  style="background-color: #ffffff;font-weight: normal;font-size: 12px; width: 31%"><?php echo $row[TimeCheckIn]?></td>
							<td class="rf-dt-shdr-c"  style="background-color: #ffffff;font-weight: normal;font-size: 12px; width: 31%"><?php echo $row[TimeCheckOut]?></td>
						</tr>
						<?php }?>
					</thead>
				</table>
			</div>
		</div>
 -->

	</div>
</div>
